<html>
	<head>
		<meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
        <title>图库</title>
        <meta name="keywords" content="图库">
        <meta name="description" content="图库">
        <meta name="_token" content="{{ csrf_token() }}"/>
        <link href="{{asset('static/css/bootstrap.min.css')}}" rel="stylesheet">
        <link href="{{asset('static/css/materialdesignicons.min.css')}}" rel="stylesheet">
        <link href="{{asset('static/css/style.min.css')}}" rel="stylesheet">
        <link href="{{asset('static/common/css/img.css')}}" rel="stylesheet">
	</head>
	<body>
		<div class="container-fluid">
			<form class="search-bar" action="{{url('image/index')}}" method="post">
			<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
			<input type="hidden" id="id" name="id" value="<?php echo !empty($params['id']) ? $params['id'] : '';?>"/>
			<input type="hidden" id="group_id" name="group_id" value="<?php echo !empty($params['group_id']) ? $params['group_id'] : '';?>"/>
        	<div class="row">
          		<div class="col-lg-3 col-md-3">
          			<div class="row">
          				<div class="col-lg-3 col-md-3">
          					<button class="btn btn-info addGroup" type="button">添加分组</button>
          				</div>
          				<div class="col-lg-9 col-md-9">
                          <div class="input-group">
                            <input type="text" class="form-control" id="group_name" name="group_name" placeholder="请输入分组名称" value="<?php echo !empty($params['group_name']) ? $params['group_name'] : ''; ?>">
                            <span class="input-group-btn">
                              <button class="btn btn-default searchGroup" type="button">搜索</button>
                            </span>
                          </div>
                        </div>
          			</div>
          			<div class="row" style="height:510px; overflow-y: auto;border: 1px solid #ddd;">
          				<div class="col-lg-12 col-md-12">
          					<div class="row area-3 area area-flex dad-droppable group_div">
          						<?php if(!empty($group_list)){ ?>
          						<?php foreach($group_list as $k=>$v){?>
                                  <div class="item <?php if((!empty($params['group_id']) && $params['group_id'] == $v['id']) || (empty($params['group_id']) && $k == 0)){?>active<?php } ?>">
                                  	<a class="group_a" href="javascript:void(0);" data-id="{{$v['id']}}"><span>{{$v['group_name']}}</span></a>
                                  	<?php if($v['id'] > 1){?>
                                  	<div class="btn-group">
                                    	<a class="btn btn-xs btn-info editGroup" data-href="{{url('image/add_group')}}" data-id="{{$v['id']}}" href="javascript:void(0)" title="编辑"><i class="mdi mdi-pencil"></i></a>
                                    	<a class="btn btn-xs btn-danger deleteGroup" data-href="{{url('image/delete_group')}}" data-id="{{$v['id']}}" data-confirm="确定删除图片分组" href="javascript:void(0)" title="删除"><i class="mdi mdi-window-close"></i></a>
                                    </div>
                                  	<?php }?>
                                  </div>
                                <?php }}?>
                          	</div>
          				</div>
          			</div>
          		</div>
          		<div class="col-lg-9 col-md-9">
          			<div class="row">
          				<div class="col-lg-3 col-md-3">
          					<div class="input-group" style="width: 100%;">
              					<select class="form-control" id="sortby" name="sortby" style="height: 38px;width: 100%;">
                                    <option value="">请选择</option>
                                    <option value="time_asc" <?php if(isset($params['sortby']) && $params['sortby'] == 'time_asc'){?>selected<?php }?>>按时间升序</option>
                                    <option value="time_desc" <?php if(isset($params['sortby']) && $params['sortby'] == 'time_desc'){?>selected<?php }?>>按时间倒序</option>
                                    <option value="name_asc" <?php if(isset($params['sortby']) && $params['sortby'] == 'name_asc'){?>selected<?php }?>>按名字升序</option>
                                    <option value="name_desc" <?php if(isset($params['sortby']) && $params['sortby'] == 'name_desc'){?>selected<?php }?>>按名字倒序</option>
                              	</select>
                          	</div>
          				</div>
          				<div class="col-lg-7 col-md-7">
                          <div class="input-group">
                            <input type="text" class="form-control" id="img_name" name="img_name" placeholder="请输入图片名称" value="<?php echo !empty($params['img_name']) ? $params['img_name'] : '';?>">
                            <span class="input-group-btn">
                              <button class="btn btn-default" type="submit">搜索</button>
                            </span>
                          </div>
                        </div>
                        <div class="col-lg-2 col-md-2 file_upload" style="padding-left: 2rem;">
                          <form id="fileForm" action="{{url('image/upload')}}" method="post" enctype="multipart/form-data">  
                          	<input type="file" class="file" name="img_file" id="img_file" accept="image/*">
                          	<button class="btn btn-success" type="button">上传图片</button>
                          </form>
                        </div>
          			</div>
          			<div class="row" style="padding: 1rem;">
          				<div class="col-lg-12 col-md-12">
          					<?php if(!$img_list->isEmpty()){ ?>
          						<ul class="list-inline clearfix lyear-uploads-pic img_list">
          						<?php foreach($img_list as $k=>$v){ ?>
              						<li>
                                      <figure>
                                        <img src="{{asset($v->img_url)}}" alt="{{$v->img_name}}">
                                        <figcaption>
                                          <a class="btn btn-round btn-square btn-primary" href="{{asset($v->img_url)}}" data-id="{{$v->id}}" target="_blank" title="查看图片"><i class="mdi mdi-eye"></i></a>
                                          <a class="btn btn-round btn-square btn-success select_img" href="javascript:void(0)" data-url="{{asset($v->img_url)}}" data-img-url="{{$v->img_url}}" data-id="{{$v->id}}" title="选择图片"><i class="mdi mdi-checkbox-marked-circle-outline"></i></a>
                                          <a class="btn btn-round btn-square btn-danger delete_img" href="javascript:void(0)" data-id="{{$v->id}}" title="删除图片" data-confirm="确定删除图片"><i class="mdi mdi-delete"></i></a>
                                        </figcaption>
                                      </figure>
                                      <div class="img_name" title="{{$v->img_name}}"><span>{{$v->img_name}}</span></div>
                                    </li>
          						<?php }?>
          						</ul>
          						{!! $pager !!}
          					<?php }else{ ?>
          						<div style="text-align: center;"><h5 style="color:red;">暂无图片!</h5></div>
          					<?php }?>
          				</div>
          			</div>
          		</div>
          	</div>
          	</form>
		</div>	
	</body>
	<script type="text/javascript" src="{{asset('static/js/jquery-1.11.3.min.js')}}"></script>
	<script type="text/javascript" src="{{asset('static/js/layer/layer.js')}}"></script>
	<script type="text/javascript" src="{{asset('static/common/js/image.js')}}"></script>
	<script type="text/javascript">
        $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') }})
    </script>
</html>